var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/functionalComponent/panel/index.tsx
var panel_exports = {};
__export(panel_exports, {
  Panel: () => Panel
});
module.exports = __toCommonJS(panel_exports);
var import_react = __toESM(require("react"));
var import_util = require("../../util");
var import_fullPage = require("../fullPage");
function InnerPanel({
  title,
  extra = null,
  children,
  style,
  className,
  bodyStyle,
  headerStyle,
  autoFit = false,
  collapsible = false,
  showArrow = true,
  showPrefix = true,
  compact = false,
  open = true,
  onOpenChange,
  innerRef,
  blankStyle,
  flexDirection
}) {
  const [innerOpen, setInnerOpen] = (0, import_util.useRefValue)(open, true);
  const layoutStyle = {
    backgroundColor: "#fff",
    borderRadius: 2,
    marginBottom: `${autoFit || compact ? 0 : "var(--inner-margin, 16px)"}`,
    ...style
  };
  if (!innerOpen) {
    delete layoutStyle.minHeight;
    delete layoutStyle.flex;
    delete layoutStyle.height;
  }
  (0, import_util.useUpdateEffect)(() => {
    if (innerOpen !== open) {
      onOpenChange == null ? void 0 : onOpenChange(innerOpen);
    }
  }, [innerOpen]);
  const titleClick = (e) => {
    if (!collapsible) {
      return;
    }
    if (!e || e.target === e.currentTarget || e.target.parentNode === e.currentTarget || import_util.iup.closest(e.target, (el) => {
      var _a;
      return (_a = el.classList) == null ? void 0 : _a.contains("iup-collapse-handle");
    })) {
      setInnerOpen == null ? void 0 : setInnerOpen(!innerOpen);
      return;
    }
  };
  const hasHeader = !!(collapsible || title || extra);
  const offset = compact ? -2 : 0;
  const getHeader = (innerStyle = {}) => {
    if (hasHeader) {
      return /* @__PURE__ */ import_react.default.createElement(
        "div",
        {
          className: import_util.iup.classNames("iup-panel-title"),
          onClick: titleClick,
          style: {
            height: "auto",
            minHeight: compact ? 36 : 45,
            cursor: `${collapsible ? "pointer" : "default"}`,
            whiteSpace: "nowrap",
            display: "flex",
            alignItems: "center",
            borderBottom: "1px solid rgba(0, 0, 0, 0.06)",
            paddingRight: 12,
            ...innerStyle,
            ...headerStyle
          }
        },
        showPrefix && /* @__PURE__ */ import_react.default.createElement("div", { style: { backgroundColor: "var(--primary-color)", width: 4, height: 12, flexShrink: 0 } }),
        /* @__PURE__ */ import_react.default.createElement(
          "div",
          {
            className: "iup-collapse-handle",
            style: { fontSize: 16 + offset, marginLeft: showPrefix ? 12 + offset : 16 + offset, fontWeight: 600 }
          },
          title || ""
        ),
        /* @__PURE__ */ import_react.default.createElement(
          "span",
          {
            ref: innerRef,
            className: "iup-collapse-handle",
            style: { minWidth: 30, textAlign: "right", flex: 1, width: 0, ...blankStyle }
          }
        ),
        extra,
        collapsible && showArrow ? /* @__PURE__ */ import_react.default.createElement("span", { style: { fontSize: 0, marginLeft: 8 } }, /* @__PURE__ */ import_react.default.createElement(
          import_util.RightOutlined,
          {
            className: "iup-collapse-handle",
            style: { transition: "all .3s ease", fontSize: 16, transform: `rotate(${innerOpen ? 90 : 0}deg)` }
          }
        )) : null
      );
    }
    return null;
  };
  if (children) {
    return /* @__PURE__ */ import_react.default.createElement(import_util.Layout, { autoFit, className: import_util.iup.classNames("iup-panel", className), style: layoutStyle }, getHeader(), /* @__PURE__ */ import_react.default.createElement(
      import_util.Layout.Flex,
      {
        direction: flexDirection,
        style: { padding: 16 + offset, ...bodyStyle, display: `${innerOpen ? "block" : "none"}` }
      },
      children
    ));
  }
  if (hasHeader) {
    return /* @__PURE__ */ import_react.default.createElement("div", { className: import_util.iup.classNames("iup-panel", className), style: layoutStyle }, getHeader({ borderBottom: 0 }));
  }
  return null;
}
var Panel = import_react.default.forwardRef(
  ({ fullScreen = false, ...props }, ref) => {
    const hasHeader = !!(props.collapsible || props.title || props.extra);
    const innerRef = (0, import_react.useRef)(null);
    if (fullScreen && hasHeader) {
      return /* @__PURE__ */ import_react.default.createElement(import_fullPage.FullPage, { ref, getIconContainer: () => innerRef.current, ...fullScreen === true ? {} : fullScreen }, /* @__PURE__ */ import_react.default.createElement(InnerPanel, { ...props, innerRef }));
    } else {
      return /* @__PURE__ */ import_react.default.createElement(InnerPanel, { ...props });
    }
  }
);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  Panel
});
